package com.aggregate.pay.payeco.test.client;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

import com.aggregate.pay.common.RequestClient;
import com.aggregate.pay.payeco.test.StringToObjectTest;

public abstract class AbstractRequestClient implements RequestClient {

	@Override
	public String request(String server, String queryString) {
		InputStream is_ = StringToObjectTest.class.getResourceAsStream(getExampleReusltXmlFileName());
		ByteArrayOutputStream os_ = new ByteArrayOutputStream();
		byte[] b = new byte[1024];
		try (InputStream is=is_; ByteArrayOutputStream os=os_) {
			int l = is.read(b);
			while (l != -1) {
				os.write(b, 0, l);
				l = is.read(b);
			}
			return os.toString("UTF-8");
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}
	
	public abstract String getExampleReusltXmlFileName();

}
